package sv.view;

import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
import sv.main.*;

public class Tile extends JPanel {
	
	private byte x;
	private byte y;
	
	private boolean hover;
	private Color hoverChangeBackColor;
	
	public Tile(byte x, byte y){
		super();
		this.x = x;
		this.y = y;
		
		hover = false;
		hoverChangeBackColor = Color.blue;
	}
	
	public byte X(){
		return x;
	}
	
	public byte Y(){
		return y;
	}
	
	public synchronized void setHover(Color color) {
		hoverChangeBackColor = getBackground();
		setBackground(color);
		hover = true;
	}
	
	public synchronized void removeHover() {
		hover = false;
		setBackground(hoverChangeBackColor);
	}
	
	public synchronized void setBackground(Color color) {
		if (hover) {
			hoverChangeBackColor = color;
		}
		else {
			super.setBackground(color);
		}
	}
}
